// copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
// see COPYRIGHT for reuse legalities
//

#import "RIBQuadric.h"
#import <stdio.h>


@implementation RIBQuadric

+ initialize { return [RIBQuadric setVersion:1], self; }

- (BOOL)isGeometry { return YES; }

- init
{
  thetaMax = 360.0;

  [super init];

  return self;
}

- setThetaMax:(RtFloat)newThetaMax 
     n:(int)newN tokens:(RtToken *)newTokens parms:(RtPointer *)newParms archiveVector:(char **)newArchiveVector 
     printfTypeVector:(int *)newPrintfTypeVector printfNVector:(int *)newPrintfNVector
{  
   thetaMax = newThetaMax;
   [self setN:newN tokens:newTokens parms:newParms archiveVector:newArchiveVector printfTypeVector:newPrintfTypeVector printfNVector:newPrintfNVector];

   dirtyBoundingBox = TRUE;

   return self;
}

- setThetaMax:(RtFloat)newThetaMax { thetaMax = newThetaMax; dirtyBoundingBox = TRUE; return self; }

- (RtFloat)thetaMax { return thetaMax; }

- (BOOL)hasboundingBox { return YES; }


- (BOOL)isMoot
{
  if (!thetaMax) { return YES; }
  return NO;
}

- (BOOL)theSameAs:otherRIBCommand
{
  if (thetaMax != [otherRIBCommand thetaMax])
  {  return NO;
  }

  return [super theSameAs:otherRIBCommand];
}



- (BOOL)isMotionBlurrable { return YES; }

#define typeVector "f"
#define typeValues &thetaMax

- read:(NXTypedStream*)stream 
{
  int  version;


  [super read:stream];

NX_DURING
  version = NXTypedStreamClassVersion(stream,"RIBQuadric");
  if (version == 0) NXReadTypes(stream,"i",&version), version=1;
  if (version == 1)
  {  NXReadTypes(stream,typeVector,typeValues);
  } 
NX_HANDLER
   NXLogError("in read: %s, exception [%d] raised.\n", 
                 [[self class] name], NXLocalHandler.code);
   return nil;
NX_ENDHANDLER

  return self; 
}

- write:(NXTypedStream*)stream 
{
  [super write:stream];

  NXWriteTypes(stream,typeVector, typeValues);

  return self;
}


@end
